<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<title>管理员登录</title>
	<link rel="stylesheet" type="text/css" href="css/normalize.css">
	<link rel="stylesheet" type="text/css" href="css/login.css">
	<script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
	<div class="wrapper">

	<div class="container">
		<h1>管理员登录</h1>
		<form class="form" method="post" action="">
			<input type="text" name="username" id="username" placeholder="请输入管理员账号" />
			<input type="password" name="password" id="password" placeholder="请输入管理员密码" />
			<button type="button" id="login-button">登录</button>
		</form>
	</div>
	
	<ul class="bg-bubbles">
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
	</ul>
	
</div>
	
</body>
<script type="text/javascript">
	$("#login-button").on('click',function(){
		var flag = true;
		var username = $('#username').val();
		var password = $('#password').val();
		if (username == "") {
			alert("请输入用户名！");
			flag = false;
		}else if (password == "") {
			alert("请输入密码！");
			flag = false;
		}
		if (flag) {
			$.ajax({
		       	 type: 'post',
		   	     url: "user/login",
		   	     data:{
		   	     	username:username,
		   	     	password:password
		   	     },
   	     		dataType:'json',    
   	     		success: function (data){
   	     			if (data.code != 200) {
   	     				alert(data.msg);
   	     			}else{
   	     				window.location.href = "index/home";
   	     			}
   	     		}
	    	});
		}
	});  


</script>
</html>